import React, { Component } from 'react';
import {connect} from 'react-redux'
import { getHandleList} from '../../actions/handleListActions';
import style from './footNav.scss'

class FootNav extends Component {
    constructor(props) {
        super(props);
        this.state = {
					footNavState:''
        };
    }

		componentWillMount(){
			this.props.dispatch(getHandleList({},(data)=>{
				if(data.length){
					this.setState({
						footNavState: true
					})
				}else {
					this.setState({
						footNavState: false
					})
				}
			}))
		}

		toUrl(url) {
			this.context.router.push(url);
		}

    render() {
				let choice =this.props.choice==2?true:false;
        return (

            <div>
	            {/*底部切换菜单 start*/}
	            {/*<div className={style.footNav+' '+'border_top_1'} onClick={(e)=>{this.toUrl(this.props.url?this.props.url:'home');e.stopPropagation() }}>*/}
	            <div className={style.footNav+' '+'border_top_1'} onClick={(e)=>{this.toUrl(this.state.footNavState?'handleList':'home');e.stopPropagation() }}>
		            <div className={style.visaNav}>
			            <span style={choice?{color:'#ababab'}:{}}><img src={choice?"./images/visaNav_s.png":"./images/visaNav.png"} alt="港澳签注"/>港澳签注</span>
		            </div>
		            <div className={style.orderNav} onClick={(e)=>{this.toUrl(`orderList${this.props.urlType?this.props.urlType:''}`);e.stopPropagation()}}>
			            <span style={choice?{color:'#00B488'}:{}}><img src={choice?"./images/orderNav_s.png":"./images/orderNav.png"} alt="我的订单"/>我的订单</span>
		            </div>
	            </div>
	            {/*底部切换菜单 end*/}
            </div>
        )
    }
}

FootNav.defaultProps = {}

//使用context
FootNav.contextTypes = {
	router: React.PropTypes.object.isRequired
};

export default connect()(FootNav);
